import 'dart:async';
import "dart:io";
import 'dart:convert';

import 'package:binance_spot/binance_spot.dart';
import 'package:flutter/services.dart';
import 'package:new_keyboard_shortcuts/keyboard_shortcuts.dart';
import 'util.dart';
import 'package:flutter/material.dart';

class LeftView extends StatelessWidget{
  const LeftView({Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Flexible(
      flex: 1,
      child: Flex(
        direction: Axis.horizontal,
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.start,
        verticalDirection: VerticalDirection.down,
        textDirection: TextDirection.rtl,
        children: const [
          OrderList(),
          ParamsView(),
        ],
      ),
    );
  }
}

class ParamsView extends StatelessWidget{
  const ParamsView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Flexible(
        flex: 1,
        child: Flex(
          direction: Axis.vertical,
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,

          children: const  [
            ParamsViewTable(),
            NumSetting(),
            ParamSetting(),
            ParamSetting(),
            ColorSetting(),
          ],
        ),

    );

  }

}

class NumSetting extends StatefulWidget{
  const NumSetting({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _NumSetting();
}

class _NumSetting extends State<NumSetting>{
  final TextEditingController _titleTxt = TextEditingController();

  late Duration duration;
  late Timer timer;

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    duration = const Duration(seconds: 1);
    Timer.periodic(duration, (timer) {
      setState(() {

      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    // 取消定时器
    timer.cancel();
  }

  @override
  void initState() {
    super.initState();

  }

  @override
  Widget build(BuildContext context) {
    return Flexible(
        flex: 1,
        child:  Flex(
      direction: Axis.vertical,
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      verticalDirection: VerticalDirection.down,
      children: [
        Flexible(
          child: Text("当前分仓数:"+GlobalParams.changwei.toString()+"，当前交易对:"+GlobalParams.title,textAlign: TextAlign.center,style: TextStyle(color: Colors.red),),
        ),

        Flexible(
          child: Flex(
              direction: Axis.horizontal,
              children: [
                Flexible(
                  flex: 1,
                  child: TextField(
                      controller: _titleTxt,
                      keyboardType: TextInputType.number,
                      decoration: InputDecoration(
                        hintText: GlobalParams.changwei.toString(),
                        prefixIcon: Icon(Icons.gavel_sharp),
                        contentPadding: EdgeInsets.only(top: 5, left: 10),
                      )
                  )
                ),
                Flexible(
                  flex: 1,
                  child: KeyBoardShortcuts(
                    keysToPress: {LogicalKeyboardKey.f11},
                    onKeysPressed: (){
                      setState(() {
                        GlobalParams.changwei = int.parse(_titleTxt.text);
                      });
                    },
                    child: ElevatedButton(
                      onPressed: () {
                        setState(() {
                          GlobalParams.changwei = int.parse(_titleTxt.text);
                        });
                      },
                      child:Text('确定',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                    ),
                  ),
                )
              ],
          ),
        ),
      ],
    ),
    );
  }

}

class ColorSetting extends StatefulWidget {
  const ColorSetting({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => colorSetting();

}

class colorSetting extends State<ColorSetting>{
  @override
  Widget build(BuildContext context) {
    return Flexible(
      flex: 2,
      child: Flex(
        direction: Axis.vertical,
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        verticalDirection: VerticalDirection.down,
        textDirection: TextDirection.rtl,
        children: [
          Container(
            child: const Text("颜色",textAlign: TextAlign.center),
            width: 1000,
          ),
          Flexible(
            child: Table(

              //表格边框样式
              border: TableBorder.all(
                color: const Color(0x11123456),
                width: 2.0,
                style: BorderStyle.solid,
              ),
              children:  [
                const TableRow(
                  //第一行样式 添加背景色
                    decoration: BoxDecoration(
                      color: Colors.grey,
                    ),
                    children: [
                      Text('成交明细',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text('挂单板块',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                    ]
                ),
                TableRow(
                    children: [
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.form_yellow_is = ! GlobalParams.form_yellow_is;
                                  });
                                },
                                child:Text(GlobalParams.form_yellow_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('黄色 '+GlobalParams.form_yellow.toString()+"k",style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.pankou_yellow_is = ! GlobalParams.pankou_yellow_is;
                                  });
                                },
                                child:Text(GlobalParams.pankou_yellow_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('黄色 '+GlobalParams.pankou_yellow.toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),

                    ]
                ),
                TableRow(
                    children: [
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.form_red_is = ! GlobalParams.form_red_is;
                                  });
                                },
                                child:Text(GlobalParams.form_red_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('红色 '+GlobalParams.form_red.toString()+"k",style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.pankou_red_is = ! GlobalParams.pankou_red_is;
                                  });
                                },
                                child:Text(GlobalParams.pankou_red_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('红色 '+GlobalParams.pankou_red.toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                    ]
                ),
                TableRow(
                    children: [
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.form_blue_is = ! GlobalParams.form_blue_is;
                                  });
                                },
                                child:Text(GlobalParams.form_blue_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('蓝色 '+GlobalParams.form_blue.toString()+"k",style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.pankou_blue_is = ! GlobalParams.pankou_blue_is;
                                  });
                                },
                                child:Text(GlobalParams.pankou_blue_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('蓝色 '+GlobalParams.pankou_blue.toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                    ]
                ),
                TableRow(
                    children: [
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.form_wihte_is  = ! GlobalParams.form_wihte_is ;
                                  });
                                },
                                child: Text(GlobalParams.form_wihte_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),
                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('白色 '+GlobalParams.form_wihte.toString()+"k",style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                      Flex(
                        direction: Axis.horizontal,
                        children: [
                          Flexible(
                              flex: 1,
                              fit: FlexFit.tight,
                              child:ElevatedButton(
                                onPressed: () {
                                  setState(() {
                                    GlobalParams.pankou_wihte_is = ! GlobalParams.pankou_wihte_is;
                                  });
                                },
                                child: Text(GlobalParams.pankou_wihte_is ? '开启' : '关闭',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              ),

                          ),
                          Flexible(
                              flex: 2,
                              fit: FlexFit.tight,
                              child: Text('白色 '+GlobalParams.pankou_wihte.toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)
                          ),
                        ],
                      ),
                    ]
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

}

class ParamsViewTable extends StatefulWidget{
  const ParamsViewTable({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => ParamsViewTableState();

}

class ParamsViewTableState extends State<ParamsViewTable> {
  int _count = 0;
  final _table_data = [
    ['买1','1','分仓','卖20','/','分仓',LogicalKeyboardKey.question,LogicalKeyboardKey.numpad1],
    ['买2','2','分仓','卖19','.','分仓',LogicalKeyboardKey.greater,LogicalKeyboardKey.numpad2],
    ['买3','3','分仓','卖18',',','分仓',LogicalKeyboardKey.less,LogicalKeyboardKey.numpad3],
    ['买4','4','分仓','卖17','M','分仓',LogicalKeyboardKey.keyM,LogicalKeyboardKey.numpad4],
    ['买5','5','分仓','卖16','N','分仓',LogicalKeyboardKey.keyN,LogicalKeyboardKey.numpad5],
    ['买6','6','分仓','卖15','B','分仓',LogicalKeyboardKey.keyB,LogicalKeyboardKey.numpad6],
    ['买7','7','分仓','卖14','V','分仓',LogicalKeyboardKey.keyV,LogicalKeyboardKey.numpad7],
    ['买8','8','分仓','卖13','C','分仓',LogicalKeyboardKey.keyC,LogicalKeyboardKey.numpad8],
    ['买9','9','分仓','卖12','X','分仓',LogicalKeyboardKey.keyX,LogicalKeyboardKey.numpad9],
    ['买10','0','分仓','卖11','Z','分仓',LogicalKeyboardKey.keyZ,LogicalKeyboardKey.numpad0],
    ['买11','Q','分仓','卖10',':','分仓',LogicalKeyboardKey.colon,LogicalKeyboardKey.keyQ],
    ['买12','W','分仓','卖9','L','分仓',LogicalKeyboardKey.keyL,LogicalKeyboardKey.keyW],
    ['买13','E','分仓','卖8','K','分仓',LogicalKeyboardKey.keyK,LogicalKeyboardKey.keyE],
    ['买14','R','分仓','卖7','J','分仓',LogicalKeyboardKey.keyJ,LogicalKeyboardKey.keyR],
    ['买15','T','分仓','卖6','H','分仓',LogicalKeyboardKey.keyH,LogicalKeyboardKey.keyT],
    ['买16','Y','分仓','卖5','G','分仓',LogicalKeyboardKey.keyG,LogicalKeyboardKey.keyY],
    ['买17','U','分仓','卖4','F','分仓',LogicalKeyboardKey.keyF,LogicalKeyboardKey.keyU],
    ['买18','I','分仓','卖3','D','分仓',LogicalKeyboardKey.keyD,LogicalKeyboardKey.keyI],
    ['买19','O','分仓','卖2','S','分仓',LogicalKeyboardKey.keyS,LogicalKeyboardKey.keyO],
    ['买20','P','分仓','卖1','A','分仓',LogicalKeyboardKey.keyA,LogicalKeyboardKey.keyP],
  ];
  API api = API();

  @override
  Widget build(BuildContext context) {



    return Flexible(
      flex: 5,

      child: Flex(
          direction: Axis.vertical,
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          verticalDirection: VerticalDirection.down,
          textDirection: TextDirection.rtl,
          children: [
            const Flexible(
                flex:1,
                child: SizedBox(
                  width: 1000,
                  child: Text("买盘盘口参数设置",textAlign: TextAlign.center),
            )),
            Flexible(
                flex:6,
                fit: FlexFit.tight,
                child: SizedBox(
                  width: 1000,
                  child: Table(

                        //表格边框样式
                        border: TableBorder.all(
                          color: const Color(0x11123456),
                          width: 2.0,
                          style: BorderStyle.solid,
                        ),
                        children: InitTable(),


                  ),
                ))

          ],
      )
    );
  }


  List<TableRow> InitTable(){
    List<TableRow> tableChild = [
      const TableRow(
        //第一行样式 添加背景色
          decoration: BoxDecoration(
            color: Colors.grey,
          ),
          children: [
            Text('挡位',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
            Text('热键',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
            Text('仓位',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
            Text('挡位',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
            Text('热键',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
            Text('仓位',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
          ]
      ),
    ];

    for(var i in _table_data){
      tableChild.add(TableRow(
          children: [
            KeyBoardShortcuts(
              keysToPress: {LogicalKeyboardKey.altLeft,i[7] as LogicalKeyboardKey},
              onKeysPressed: () {
                print(i[4].toString()+'shiftLeft');
                setState(() {
                  api.get(int.parse((i[0] as String).replaceFirst('买', '')),true, i[2]=='分仓' ? true : false);
                });

              },
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(i[0].toString(),textAlign: TextAlign.center,),
                  ],
                ),
              ),
            ),


            KeyBoardShortcuts(
              keysToPress: {LogicalKeyboardKey.controlLeft,i[7] as LogicalKeyboardKey},
              onKeysPressed: () {
                print(i[1]);
                setState(() {
                  api.delete(int.parse((i[0] as String).replaceFirst('买', '')),true, i[2]=='分仓' ? true : false);
                });

              },
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(i[1].toString(),textAlign: TextAlign.center,),
                  ],
                ),
              ),
            ),
           TextButton(
             onPressed: () { setState(() {
               i[2] = (i[2]=='分仓' ? '全仓' : '分仓');
             }); },
             child:  Text(i[2].toString(),textAlign: TextAlign.center,style: TextStyle(backgroundColor: i[2]=='全仓' ? Color(0xff0000ff) : Color(0x00000000),color: i[2]=='全仓' ? Color(0xffffffff) : Color(0xff000000)),),


           ),
            KeyBoardShortcuts(
              keysToPress: {LogicalKeyboardKey.altLeft,i[6] as LogicalKeyboardKey},
              onKeysPressed: () {
                print(i[4].toString()+'shiftLeft');
                setState(() {
                  api.get(int.parse((i[3] as String).replaceFirst('卖', '')),true, i[2]=='分仓' ? true : false);
                });

              },
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(i[3].toString(),textAlign: TextAlign.center,),
                  ],
                ),
              ),
            ),
            KeyBoardShortcuts(
              keysToPress: {LogicalKeyboardKey.controlLeft,i[6] as LogicalKeyboardKey},
              onKeysPressed: () {
                  print(i[4]);
                  setState(() {
                    api.delete(int.parse((i[3] as String).replaceFirst('卖', '')),true, i[2]=='分仓' ? true : false);
                  });

                },
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(i[4].toString(),textAlign: TextAlign.center,),
                  ],
                ),
              ),
            ),
            TextButton(
              onPressed: () { setState(() {
                i[5] = (i[5]=='分仓' ? '全仓' : '分仓');
              }); },
              child:  Text(i[5].toString(),textAlign: TextAlign.center,style: TextStyle(backgroundColor: i[5]=='全仓' ? Color(0xff0000ff) : Color(0x00000000),color: i[5]=='全仓' ? Color(0xffffffff) : Color(0xff000000)),),


            ),

          ]
      ));
    }

    return tableChild;
  }
}

//参数设置
class ParamSetting extends StatefulWidget{
  const ParamSetting({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => ParamSettingWidgrt();

}

class ParamSettingWidgrt extends State<ParamSetting>{
  @override
  Widget build(BuildContext context) {
    return Flexible(
      flex: 1,
            child: Flex(
              direction: Axis.vertical,
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              verticalDirection: VerticalDirection.down,
              textDirection: TextDirection.rtl,
              children: [
                Container(
                  child: Text("参数设置",textAlign: TextAlign.center),
                  width: 1000,
                ),
                Container(
                  child: Text("挂单模式迅速切换",textAlign: TextAlign.center),
                  width: 1000,
                ),
                Flexible(
                    child: Table(

                      //表格边框样式
                      border: TableBorder.all(
                        color: const Color(0x11123456),
                        width: 2.0,
                        style: BorderStyle.solid,
                      ),
                      children: const [
                        TableRow(
                          //第一行样式 添加背景色
                            decoration: BoxDecoration(
                              color: Colors.grey,
                            ),
                            children: [
                              Text('模式',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              Text('热键',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                          ]
                        ),
                        TableRow(
                            children: [
                              Text('模式1',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              Text('F9',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                            ]
                        ),
                        TableRow(
                            children: [
                              Text('模式2',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                              Text('F10',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                            ]
                        ),
                      ],
                    ),
                ),
              ],
            ),
        );
  }

}


//成交薄
class OrderList extends StatelessWidget{
  const OrderList({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Flexible(
        flex: 1,
        child: Column(
          children:  const [
            FilterSettings(),
            MyMoney(),
            DataList(),
          ],
        )


    );

  }

}

class MyMoney extends StatefulWidget{
  const MyMoney({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() =>_MyMoney();

}

class _MyMoney extends State<MyMoney> {

  String lastEventData = "";

  BinanceSpot binanceSpot = BinanceSpot(
    key: "RCzHneTvJHxYMP4WvmJWXO7GMHNSMebuhWswiuLtYT8nFnaZ9sf4jBaH8rkO5ZaC",
    secret: "A8D92mZXRsAOKWS7QLKmxUddljAbnZV733DM6e22YOSirEQFdj03yYNt0gBdsKJ5",
  );

  @override
  void initState(){
    super.initState();
  }

  void getTradablePairs() async {
    var response = await binanceSpot.accountInformation();

      //Future<Either<String, AccountInfo>>
    for (var element in response.right.balances) {
      if( ['USDT','BUSD','BTC','BNB'].contains(element.asset )){
        GlobalParams.moneys[element.asset] = element.free;
      }
    }
  setState(() {

  });
    print('List<Balance>'+ GlobalParams.moneys.toString());
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 200,
      child: Flex(
        direction: Axis.vertical,
        children: [
          Flexible(
            child: Flex(
              direction: Axis.horizontal,
              children: [
                Flexible(flex: 1,child: Text('当前个人资金')),
                Flexible(
                    flex: 1,
                    child: ElevatedButton(
                      onPressed: () {
                        getTradablePairs();

                      },
                      child: Text('刷新'),
                    )),
              ],
            ),

          ),
          Flexible(
            child: Table(

              //表格边框样式
              border: TableBorder.all(
                color: const Color(0x11123456),
                width: 2.0,
                style: BorderStyle.solid,
              ),
              children: [
                const TableRow(
                  //第一行样式 添加背景色
                    decoration: BoxDecoration(
                      color: Colors.grey,
                    ),
                    children: [
                      Text('USTD',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text('BUSD',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text('BTC',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text('BNB',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                    ]
                ),
                TableRow(
                    children: [
                      Text( GlobalParams.moneys['USDT'].toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text( GlobalParams.moneys['BUSD'].toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text( GlobalParams.moneys['BTC'].toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                      Text( GlobalParams.moneys['BNB'].toString(),style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,),
                    ]
                ),
              ],
            ),

          ),
        ],
      ),
    );
  }

}

class FilterSettings extends StatefulWidget{
  const FilterSettings({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => FilterSettingsWedget ();

}

class DataList extends StatefulWidget{
  const DataList({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => DataListWidget();

}

class FilterSettingsWedget  extends State<StatefulWidget>{


  @override
  Widget build(BuildContext context) {

      return Container(
        height: 300,
        child: Util.FlexContainer(
            Axis.vertical,
            [
              const SizedBox(
                child: Text("塞选设置",textAlign: TextAlign.center,),
                width: 1000,
              ),
              SizedBox(
                width: 1000,
                child:  Table(

                  border: TableBorder.all(
                    color: const Color(0x11123456),
                    width: 2.0,
                    style: BorderStyle.solid,
                  ),
                  children: const [
                    TableRow(
                        children: [
                          Text("1分钟预警",textAlign: TextAlign.center,),
                          Text("5分钟预警",textAlign: TextAlign.center,),
                        ]
                    )
                  ],
                ),
              ),
              Table(
                border: TableBorder.all(
                  color: const Color(0x11123456),
                  width: 2.0,
                  style: BorderStyle.solid,
                ),
                children:  [
                  TableRow(
                      children: [
                        Util.TextCenter("成交额"),
                        Util.RedTextCenter("100",),
                        Util.TextCenter("K"),
                        Util.TextCenter("成交额"),
                        Util.RedTextCenter("500"),
                        Util.TextCenter("K"),
                      ]
                  ),
                  TableRow(
                      children: [
                        Util.TextCenter("振幅"),
                        Util.RedTextCenter("1"),
                        Util.TextCenter("%"),
                        Util.TextCenter("振幅"),
                        Util.RedTextCenter("5"),
                        Util.TextCenter("%"),
                      ]
                  )
                ],
              ),
              SizedBox(
                width: 1000,
                child:  Table(

                  border: TableBorder.all(
                    color: const Color(0x11123456),
                    width: 2.0,
                    style: BorderStyle.solid,
                  ),
                  children:  [
                    TableRow(
                        children: [
                          ElevatedButton(
                            child: Text('执行'),
                            onPressed: () {

                            },
                          ),
                          ElevatedButton(
                            child: Text('执行'),
                            onPressed: () {

                            },
                          ),
                        ]
                    )
                  ],
                ),
              ),
            ]
        ),
      );
  }

}

class DataListWidget extends State<DataList>{

  var _data = [
    ["BTC/USDT","1","1.5","500K"],
    ["BTC/USDT","1.3","1.8","320"],
    ["ETH/USDT","1.6","2.1","501K"],
    ["BTC/USDT","1.9","2.4","5320"],
    ["BTC/USDT","2.2","2.7","502K"],
    ["ETH/USDT","2.5","3","5320"],
  ];


  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 300,
      child: Table(
        border: TableBorder.all(
          color: const Color(0x11123456),
          width: 2.0,
          style: BorderStyle.solid,
        ),
        children: [
          TableRow(
              decoration: BoxDecoration(
                color: Colors.grey,
              ),
              children: [
                Util.TextCenter("列表"),
                Util.TextCenter("涨幅",),
                Util.TextCenter("振幅"),
                Util.TextCenter("成交额"),
              ]
          ),
          TableRow(
              children: [
                Util.TextCenter(_data[0][0]),
                Util.TextCenter(_data[0][1]),
                Util.TextCenter(_data[0][2]),
                Util.TextCenter(_data[0][3]),
              ]
          ),
          TableRow(
              children: [
                Util.TextCenter(_data[1][0]),
                Util.TextCenter(_data[1][1]),
                Util.TextCenter(_data[1][2]),
                Util.TextCenter(_data[1][3]),
              ]
          ),TableRow(
              children: [
                Util.TextCenter(_data[2][0]),
                Util.TextCenter(_data[2][1]),
                Util.TextCenter(_data[2][2]),
                Util.TextCenter(_data[2][3]),
              ]
          ),
          TableRow(
              children: [
                Util.TextCenter(_data[3][0]),
                Util.TextCenter(_data[3][1]),
                Util.TextCenter(_data[3][2]),
                Util.TextCenter(_data[3][3]),
              ]
          ),
          TableRow(
              children: [
                Util.TextCenter(_data[4][0]),
                Util.TextCenter(_data[4][1]),
                Util.TextCenter(_data[4][2]),
                Util.TextCenter(_data[4][3]),
              ]
          ),
          TableRow(
              children: [
                Util.TextCenter(_data[5][0]),
                Util.TextCenter(_data[5][1]),
                Util.TextCenter(_data[5][2]),
                Util.TextCenter(_data[5][3]),
              ]
          ),
        ],
      ),
    );
  }

}



